package com.pg.service.impl;


import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pg.entity.sy.EipPowerFrequency;
import com.pg.mapper.EipPowerFrequencyMapper;
import com.pg.service.EipPowerFrequencyService;

/**
 * <p>
 * 工频耐受电压 服务实现类
 * </p>
 *
 * @Author likl
 * @since 2020-10-26
 */
@Service
@DS("proxyDs")
@Primary
public class EipPowerFrequencyServiceImpl extends ServiceImpl<EipPowerFrequencyMapper, EipPowerFrequency> implements EipPowerFrequencyService {

    @Autowired
    private EipPowerFrequencyMapper eipPowerFrequencyMapper;

    @Override
    public IPage<EipPowerFrequency> selectForList(Page<EipPowerFrequency> page, EipPowerFrequency eipPowerFrequency, Date startCheckTime, Date endCheckTime) {
        LambdaQueryWrapper<EipPowerFrequency> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(eipPowerFrequency.getSupplierWorkNo())) {
            queryWrapper.like(EipPowerFrequency::getSupplierWorkNo, eipPowerFrequency.getSupplierWorkNo());
        }
        if (StringUtils.isNotEmpty(eipPowerFrequency.getCategoryType())) {
            queryWrapper.like(EipPowerFrequency::getCategoryType, eipPowerFrequency.getCategoryType());
        }
        if (StringUtils.isNotEmpty(eipPowerFrequency.getProductModel())) {
            queryWrapper.like(EipPowerFrequency::getProductModel, eipPowerFrequency.getProductModel());
        }
        if (StringUtils.isNotEmpty(eipPowerFrequency.getEquipmentName())) {
            queryWrapper.like(EipPowerFrequency::getEquipmentName, eipPowerFrequency.getEquipmentName());
        }
        if (StringUtils.isNotEmpty(eipPowerFrequency.getPdCode())) {
            queryWrapper.like(EipPowerFrequency::getPdCode, eipPowerFrequency.getPdCode());
        }
        if (startCheckTime != null) {
            queryWrapper.ge(EipPowerFrequency::getCheckTime, startCheckTime);
        }
        if (endCheckTime != null) {
            queryWrapper.le(EipPowerFrequency::getCheckTime, endCheckTime);
        }
        return eipPowerFrequencyMapper.selectPage(page, queryWrapper);
    }
}
